package main

import (
	"fmt"

	"gitee.com/wulalade/hwpack/nmcli"
)

func main() {
	outs, err := nmcli.ListConnections(true)
	if err != nil {
		fmt.Println("ListConnections is err : ", outs)
	}
	fmt.Println("out : ", outs)
	//fmt.Println(strings.Replace(outs[1].Name, " ", "\\ ", -1))

	for _, value := range outs {
		if value.Device == "eth0" {
			settings := nmcli.IpDefaults{
				DNS:         "8.8.8.8",
				Ipv4Address: "192.168.1.26/24",
				Ipv4Gateway: "192.168.1.1",
			}
			ret, err := nmcli.ModifyIp(value.Name, settings)
			fmt.Printf("ret : %v ,err: %v \n", ret, err)
			break
		}
	}

}
